package com.ywwxhz.lib.handler;

import android.app.Activity;
import android.util.Log;
import android.widget.Toast;

import com.ywwxhz.MyApplication;
import com.ywwxhz.cnbetareader.R;
import com.ywwxhz.inter.HttpCallback;
import com.ywwxhz.lib.kits.Toolkit;
import de.keyboardsurfer.android.widget.crouton.Style;

/**
 * Created by ywwxhz on 2014/11/2.
 */
public abstract class BaseHttpResponseHandler<T> extends HttpCallback<T> {
    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        Log.e(this.getClass().getSimpleName(), ex.getMessage());
        ex.printStackTrace();
        Toolkit.showCrouton(getActivity(), R.string.message_data_structure_change, Style.ALERT);
        if(MyApplication.getInstance().getDebug()){
            Toast.makeText(getActivity(),ex.toString(),Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public abstract void onSuccess(T result);

    protected abstract Activity getActivity();
}
